Skip to content

Make deploy steps for an app all use the same commit#971

Open
doshitan wants to merge 1 commit intomainfrom
doshitan/fix-cd-race-condition
Open

Make deploy steps for an app all use the same commit#971
doshitan wants to merge 1 commit intomainfrom
doshitan/fix-cd-race-condition

Conversation

@doshitan
Copy link
Contributor

@doshitan doshitan commented Nov 3, 2025

When multiple commits hit a repo in quick succession each touching a different app, it creates a race condition as each app CD action will attempt to resolve the HEAD of main, not the ref that actually triggered the workflow. So have cd-{{app_name}}.yml use the commit that triggered the workflow (on push events) if version is not provided explicitly (which will be the case for dispatch events).

That alone should fix the biggest issue, but while here ensure build-and-publish.yml resolves the commit itself only once in the get-commit-hash job, and then uses that everywhere else. This is so if it is invoked manually or a deploy manually invoked with a non-commit ref, the commit is fixed once the build starts at least.

Testing

platform-test branch: https://github.com/navapbc/platform-test/compare/doshitan/fix-cd-race-condition

Manual deploy: https://github.com/navapbc/platform-test/actions/runs/19047490583
Auto deploy: https://github.com/navapbc/platform-test/actions/runs/19047713627

When multiple commits hit a repo in quick succession each touching a
different app, it creates a race condition as each app CD action will
attempt to resolve the `HEAD` of `main`, not the ref that actually
triggered the workflow. So have `cd-{{app_name}}.yml` use the commit
that triggered the workflow (on `push` events) if `version` is not
provided explicitly (which will be the case for dispatch events).

That alone should fix the biggest issue, but while here ensure
`build-and-publish.yml` resolves the commit itself only once in the
`get-commit-hash` job, and then uses that everywhere else. This is so if
it is invoked manually or a deploy manually invoked non-commit ref, the
commit is fixed once the build starts at least.
@doshitan doshitan requested a review from sean-navapbc November 3, 2025 20:30
# Need to set a default value for when the workflow is triggered from a git push
# which bypasses the default configuration for inputs
run-name: Deploy ${{'{{'}}inputs.version || 'main' {{'}}'}} to {{ app_name }} ${{'{{'}} inputs.environment || 'dev' {{'}}'}}
run-name: Deploy ${{'{{'}} inputs.version || github.sha {{'}}'}} to {{ app_name }} ${{'{{'}} inputs.environment || 'dev' {{'}}'}}
Copy link
Contributor Author

@doshitan doshitan Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could potentially use github.ref here instead for a more skimmable name, but lean towards using what is ultimately the input.

@doshitan doshitan marked this pull request as ready for review November 3, 2025 20:35
@doshitan doshitan requested a review from a team as a code owner November 3, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants